//
//  CompanyNewsCell.m
//  NewPro
//
//  Created by RYX on 2018/10/31.
//  Copyright © 2018年 何荧红. All rights reserved.
//

#import "CompanyNewsCell.h"
#import "CompanyNewsModel.h"

@interface CompanyNewsCell ()
{
    
    __unsafe_unretained IBOutlet UIImageView *im;
    __unsafe_unretained IBOutlet UILabel *titleLa;
    __unsafe_unretained IBOutlet UIImageView *eyeIm;
    __unsafe_unretained IBOutlet UILabel *eyLa;
    __weak IBOutlet UILabel *timeLa;
}

@end

@implementation CompanyNewsCell

+ (instancetype)tempWithTableView:(UITableView *)tableView{
    
    
    CompanyNewsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CELL"];
    
    if (!cell) {
        
        cell = [self Cell];
    }
    
    return cell;
}

+ (CGFloat)getHeight{
    
    UITableViewCell *cell = [self Cell];
    return cell.frame.size.height;
    
}

+ (instancetype)Cell{
    
    ClassName
    return [[[NSBundle mainBundle] loadNibNamed:className owner:self options:nil] objectAtIndex:0];
    
}

- (void)setModel:(CompanyNewsModel *)model{
    
    [im sd_setImageWithURL:[NSURL URLWithString:model.img]];
    titleLa.text = model.bt;
    eyLa.text = [NSString stringWithFormat:@"%@ 阅读",model.readNumber];
    timeLa.text = [self getDateStringWithTimeStr:model.pushDate];
}

- (NSString *)getDateStringWithTimeStr:(NSString *)str{
    
    NSTimeInterval time=[str doubleValue]/1000;
    //传入的时间戳str如果是精确到毫秒的记得要/1000
    NSDate *detailDate=[NSDate dateWithTimeIntervalSince1970:time];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    //实例化一个NSDateFormatter对象 //设定时间格式,这里可以设置成自己需要的格式
    [dateFormatter setDateFormat:@"yyyy-MM-dd"];
    NSString *currentDateStr = [dateFormatter stringFromDate: detailDate];
    return currentDateStr;
    
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
